﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using TjZheng.Domain.Business;
using TjZheng.Domain.DataEntity;
using TjZheng.Mvc;
using System.Web.Mvc;
using TjZheng.Framework;

namespace TjZheng.CMS.Filters
{
    public class DbSetFilter : TjZhengFilter
    {
        public override void OnActionExecuting(System.Web.Mvc.ActionExecutingContext filterContext)
        {
            BizDbSetInfo objBizDbSetInfo = new BizDbSetInfo();
            DbSetInfo objDbSetInfo = objBizDbSetInfo.GetRecord(GetInt("SetId"));
            if (objDbSetInfo == null)
            {
                if (filterContext.HttpContext.Request.IsAjaxRequest())
                {
                    filterContext.Result = new JsonResult() { Data = new InvokeResult { ResultCode = "DbSetInfoNull", ResultMessage = "配置不能为空" }, ContentType = "text/plain" };
                }
                else
                {
                    filterContext.Result = new Http404Result();
                }
                return;
            }
            filterContext.Controller.ViewBag.DbSetInfo = objDbSetInfo;
        }
    }
}